# -*- coding: utf-8 -*-
"""
构建测试脚本
封装测试脚本
"""
import jsonpath
from requests import request
from json_reade import json_r
from build_log.sys_log import Logger


L = Logger('api-test')
data_01 = json_r()['test01']
data_02 = json_r()['test02']
def test01():
    req = request(method=data_01['method'],url=data_01['url'],data=data_01['data'])
    for i in data_01:
        L.logger.info(f'api中有{i}, 其值是{data_01[i]}')
    assert int(jsonpath.jsonpath(req.json(),'code')[0]) == 0

def test02():
    req = request(method=data_02['method'], url=data_02['url'], data=data_02['data'])
    for i in data_02:
        L.logger.info(f'api中有{i}, 其值是{data_02[i]}')
    assert int(jsonpath.jsonpath(req.json(),'code')[0]) == 0
